{extend name="base/base" /}
{block name="main"}
<style>
.layui-table-cell {
height: 80px;
line-height: 80px;
}
</style>
<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input searchVal" placeholder="请输入姓名" />
                </div>
                <a class="layui-btn search_btn" data-type="reload">搜索</a>
            </div>
            <!--<div class="layui-inline">
                <a class="layui-btn layui-btn-danger layui-btn-normal adduser_btn">添加</a>
            </div>-->
        </form>
    </blockquote>
    <table id="usersList" lay-filter="usersList"></table>
    <!--操作-->
    <script type="text/html" id="usersListBar">
        <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
    </script>
</form>
{/block}
{block name="script"}
<script>
    layui.use(['form','layer','table'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery, table = layui.table;

        //用户列表
        var tableIns = table.render({
            elem: '#usersList',
            url : "{:url('/admin/user-authen',array('uid'=>$uid))}",
            cellMinWidth : 95,
            page : true,
            limit:10,
            limits:[5,10,15,20],
            height : "full-125",
            id:'usersListTable',
            cols : [[
                {field: 'rid', title: 'ID', width:100, align:"center"},
                {field: 'uid', title: '会员ID', width:100, align:"center"},
                {field: 'open_id', title: 'openid', align:'center'},
                {field: 'idcard_name', title: '身份证姓名', width:350},
                {field: 'idcard_num', title: '身份证号',  align:'center'},
                {field: 'idcard_birth', title: '身份证地址',  align:'center'},
                
                {field: 'idcard_sex', title: '性别', align:'center',templet:function(d){ return (d.idcard_sex==1)?'男':'女'}},
                {field: 'auth_time', title: '认证时间', align:'center',templet:function(d){  if(d.auth_time){return layui.util.toDateString(d.c_time * 1000, "yyyy-MM-dd HH:mm:ss")}else{return '';} }},
                
                {title: '操作', width:170, templet:'#usersListBar',fixed:"right",align:"center"}
            ]]
        });

        //搜索【此功能需要后台配合，所以暂时没有动态效果演示】
        $(".search_btn").on("click",function(){
            table.reload("usersListTable",{
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    key: $(".searchVal").val()  //搜索的关键字
                }
            })
        });

        //列表操作
        table.on('tool(usersList)', function(obj){
            var layEvent = obj.event, data = obj.data;
            if(layEvent === 'edit'){ //编辑
                edit(data.uid);
            } else if(layEvent === 'del'){ //删除
                layer.confirm('确定删除操作？',{icon:3, title:'提示信息'},function(index){
                    $.post("{:url('/admin/user-authendel')}",{rid:data.rid},function(data){
                        var icon=5;
                        if(data.code){
                            icon=6;
                        }
                        layer.msg(data.msg, {icon:icon,time: 1500}, function () {
                            if(data.code){
                                obj.del();
                            }
                        });
                    })
                });
            }
        });

    })
</script>
{/block}
